<template>
  <div class="check">
  </div>
</template>

<script>
import {CheckToken,getUrlParam} from "../methods/request"
export default {
  name: 'check',
  data () {
    return {
      msg: ''
    }
  },
  computed:{
  },
  created() {
    this.checkData();
  },
  mounted(){     
  },
  methods:{
    hrefObj() {
      var localhref = window.location.href;
      var localarr = localhref.split('?')[1].split('&');
      // console.log(localarr)
      var tempObj = {};
      for (var i = 0; i < localarr.length; i++) {
        　tempObj[localarr[i].split('=')[0]] = localarr[i].split('=')[1];
      }
      return tempObj;
    },
    async checkData(){
      var hrefObj = this.hrefObj();
      await CheckToken({"appId":hrefObj.appId,"userId":hrefObj.userId,"token":hrefObj.token}).then(
                response => {
                var obj = Object.assign({}, response.data)
                if(response.rspCode=="0000"){
                  localStorage.setItem("token",obj.sessionId)
                  sessionStorage.setItem("colour",obj.colour)
                  sessionStorage.setItem("logourl",obj.logoPicUrl)
                  sessionStorage.setItem("institutionName",obj.institutionName)
                  sessionStorage.setItem('isHkb',obj.isHkb);
                  this.$router.push({
                        path:"/",
                        query:{
                        }
                  })
                }else{
                  WeixinJSBridge.call('closeWindow');
                }
                }).catch(
                error => console.log(error)
      )
    }  
  },  
  components: {
  }
}
</script>

<style scoped>

</style>
